<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .bt1 {
            position: relative;
            width: 300px;
            height: 600px;
            background-color: aqua;
        }
        
        .bt2 {
            position: absolute;
            top: 100px;
            width: 300px;
            height: 400px;
            background-color: blue;
        }
        
        .bt3 {
            position: absolute;
            top: 100px;
            width: 300px;
            height: 200px;
            background-color: blueviolet;
        }
    </style>
</head>

<body>
    <div class="bt1">
        <div class="bt2">
            <div class="bt3"></div>
        </div>
    </div>
    <script>
        var bt1 = document.querySelector('.bt1');
        var bt2 = document.querySelector('.bt2');
        var bt3 = document.querySelector('.bt3');
        bt1.addEventListener('click', function(event) {
            if (event.target == event.currentTarget) { // event.currentTarget 让触发事件的元素等于绑定事件的元素，也可以阻止事件冒泡
                console.log(1);
            }

        });
        bt2.addEventListener('click', function(event) {
            if (event.target == event.stopPropagation) { //event.stopPropagation 只阻止事件往上冒泡，不阻止事件本身
                console.log(2);
            }

        });
        bt3.addEventListener('click', function(event) {
            if (event.target == event.currentTarget) {
                console.log(3);
            }

        });
    </script>
</body>

</html>